﻿Imports HMSLibrary

Public Class CommonDataLayer

    Dim SQLQuery As String
    Public Function GetSaleChartData(ByVal ChartYear As Integer) As List(Of ChartData)
        Dim lst As New List(Of ChartData)
        Try
            Dim dr As IDataReader
            SQLQuery = "EXEC Proc_GetSalesChartData " & ChartYear
            dr = DataCommon.db.ExecuteReader(CommandType.Text, SQLQuery)
            While dr.Read
                lst.Add(New ChartData With {.Key = dr.Item("SMonth"), .Value = dr.Item("SaleAmt")})
            End While
            dr.Close()
        Catch ex As Exception
            Throw ex
        End Try
        Return lst
    End Function

    Public Function GetCollectionChartData(ByVal ChartYear As Integer) As List(Of ChartData)
        Dim lst As New List(Of ChartData)
        Try
            Dim dr As IDataReader
            SQLQuery = "EXEC Proc_GetCollectionChartData " & ChartYear
            dr = DataCommon.db.ExecuteReader(CommandType.Text, SQLQuery)
            While dr.Read
                lst.Add(New ChartData With {.Key = dr.Item("SMonth"), .Value = dr.Item("Amount")})
            End While
            dr.Close()
        Catch ex As Exception
            Throw ex
        End Try
        Return lst
    End Function

    Public Function GetPatientInflowChartData(ByVal ChartYear As Integer) As List(Of ChartData)
        Dim lst As New List(Of ChartData)
        Try
            Dim dr As IDataReader
            SQLQuery = "EXEC Proc_GetPatientInflowChartData " & ChartYear
            dr = DataCommon.db.ExecuteReader(CommandType.Text, SQLQuery)
            While dr.Read
                lst.Add(New ChartData With {.Key = dr.Item("SMonth"), .Value = dr.Item("PatientCount")})
            End While
            dr.Close()
        Catch ex As Exception
            Throw ex
        End Try
        Return lst
    End Function
End Class
